package router

import (
	"exercise/application/yiran/app/controller/admin"
	"exercise/application/yiran/app/controller/common"
	"exercise/application/yiran/app/middleware"
	"github.com/gin-gonic/gin"
)

func WebInit(engine *gin.Engine) {

	//全局异常管理,处理panic异常
	//engine.Use(middleware.Cors(), exception.Recover())
	//engine.Use(middleware.Cors(), middleware.LoggerMiddleware(), exception.RecoverV2)

	adminGroup := engine.Group("/admin/")
	adminGroup.Use(middleware.Cors())
	{
		adminGroup.GET("test", admin.NewIndexController().Index)
		//登录获取token
		adminGroup.POST("login", admin.NewLoginController().Login)
		//上传文件
		adminGroup.POST("uploader/sliceUpload", common.NewUploader().SliceUpload)
		adminGroup.POST("uploader/mergeChunks", common.NewUploader().MergeChunks)
	}

	adminGroup.Use(middleware.Cors()).Use(middleware.CheckMember())
	{
		//菜单栏
		adminGroup.GET("menu/list", admin.NewAdminMenuController().List)
		//用户详情
		adminGroup.GET("user/userList", admin.NewUserController().Detail)
		adminGroup.POST("user/addUser", admin.NewUserController().Add)
		adminGroup.POST("user/editUser", admin.NewUserController().Edit)
		adminGroup.GET("user/userListJoin", admin.NewUserController().ListJoin)

		//上传zip识别zip:解压zip校验省份文件,省份纠正,省份文件夹异常,dbf文件识别
		adminGroup.GET("dbf/recognizeDbf", admin.NewDbfController().RecognizeDbf)
		adminGroup.POST("dbf/correctionProvince", admin.NewDbfController().CorrectionProvince)
		adminGroup.GET("dbf/movingProvinceClamp", admin.NewDbfController().MovingProvinceClamp)
		adminGroup.GET("dbf/readDbf", admin.NewDbfController().ReadDbf)

		//zip解压照片识别：校验是否存在未完成的任务,校验文件夹数量,解压zip包,确认写入
		adminGroup.GET("attachment/uncompletedTasks ", admin.NewAttachmentController().UncompletedTasks)
		adminGroup.GET("attachment/checkNotice", admin.NewAttachmentController().CheckNotice)
		adminGroup.GET("attachment/unZipNotice", admin.NewAttachmentController().UnZipNotice)
		adminGroup.GET("attachment/saveNotice", admin.NewAttachmentController().SaveNotice)
		//zip分页压缩
		adminGroup.GET("attachment/zipNotice", admin.NewAttachmentController().ZipNotice)
		adminGroup.GET("attachment/createNotice", admin.NewAttachmentController().CreateNotice)

		//建筑物管理：列表,新增,编辑,详情,删除
		adminGroup.GET("jzw/jzwList", admin.NewJzwController().List)
		adminGroup.POST("jzw/addJzw", admin.NewJzwController().Add)
		adminGroup.POST("jzw/editJzw", admin.NewJzwController().Edit)
		adminGroup.GET("jzw/detail/:id", admin.NewJzwController().Detail)
		adminGroup.GET("jzw/deleted/:id", admin.NewJzwController().Deleted)

		//楼层：列表,新增,编辑,详情,删除
		adminGroup.GET("floor/list", admin.NewFloorController().List)
		adminGroup.POST("floor/add", admin.NewFloorController().Add)
		adminGroup.POST("floor/edit", admin.NewFloorController().Edit)
		adminGroup.GET("floor/detail/:id", admin.NewFloorController().Detail)
		adminGroup.GET("floor/deleted/:id", admin.NewFloorController().Deleted)

		//教室：列表,新增,编辑,详情,删除
		adminGroup.GET("room/list", admin.NewRoomController().List)
		adminGroup.POST("room/add", admin.NewRoomController().Add)
		adminGroup.POST("room/edit", admin.NewRoomController().Edit)
		adminGroup.GET("room/detail/:id", admin.NewRoomController().Detail)
		adminGroup.GET("room/deleted/:id", admin.NewRoomController().Deleted)

		//座位号：列表,新增,编辑,详情,删除,初始化房间
		adminGroup.GET("roomSeat/list", admin.NewRoomSeatController().List)
		adminGroup.POST("roomSeat/add", admin.NewRoomSeatController().Add)
		adminGroup.POST("roomSeat/edit", admin.NewRoomSeatController().Edit)
		adminGroup.GET("roomSeat/detail/:id", admin.NewRoomSeatController().Detail)
		adminGroup.GET("roomSeat/deleted/:id", admin.NewRoomSeatController().Deleted)
		adminGroup.POST("roomSeat/initRoom", admin.NewRoomSeatController().InitRoom)
		adminGroup.POST("roomSeat/resetRoom", admin.NewRoomSeatController().ResetRoom)

		//考次管理
		adminGroup.GET("examTime/list", admin.NewExamTimeController().List)
		adminGroup.POST("examTime/add", admin.NewExamTimeController().Add)
		adminGroup.POST("examTime/edit", admin.NewExamTimeController().Edit)
		adminGroup.GET("examTime/detail/:id", admin.NewExamTimeController().Detail)
		adminGroup.GET("examTime/deleted/:id", admin.NewExamTimeController().Deleted)
		adminGroup.GET("examTime/copyTime/:id", admin.NewExamTimeController().CopyTime)
		adminGroup.GET("examTime/addCache/:id", admin.NewExamTimeController().AddCache)

		//预分配用户:预分配,清空考场,自动分配考场,考场房间信息,自动分配空房间,空房间中新增一个人员
		adminGroup.GET("studentExam/preAllocate", admin.NewStudentExamController().PreAllocate)
		adminGroup.GET("studentExam/clearAllocate", admin.NewStudentExamController().ClearAllocate)
		adminGroup.GET("studentExam/autoExamRoom", admin.NewStudentExamController().AutoExamRoom)
		adminGroup.GET("studentExam/examList", admin.NewStudentExamController().ExamList)
		adminGroup.GET("studentExam/autoFills", admin.NewStudentExamController().AutoFillsEmptyRoom)

		//学生成绩规则
		adminGroup.GET("scoreRule/list", admin.NewScoreRuleController().List)
		adminGroup.POST("scoreRule/add", admin.NewScoreRuleController().Add)
		adminGroup.POST("scoreRule/edit", admin.NewScoreRuleController().Edit)
		adminGroup.GET("scoreRule/detail/:id", admin.NewScoreRuleController().Detail)
		adminGroup.GET("scoreRule/deleted/:id", admin.NewScoreRuleController().Deleted)

		//计算学生分数
		adminGroup.GET("score/initStudent", admin.NewStudentScoreController().InitStudent)
		adminGroup.GET("score/clearStudent/:rule_id", admin.NewStudentScoreController().ClearStudent)
		adminGroup.GET("score/importStudentScore", admin.NewStudentScoreController().ImportStudentScore)
		adminGroup.GET("score/updateRanking/:rule_id", admin.NewStudentScoreController().UpdateRanking)
		adminGroup.GET("score/levelGrading/:rule_id", admin.NewStudentScoreController().LevelGrading)
		adminGroup.GET("score/grading/:rule_id", admin.NewStudentScoreController().Grading)
		adminGroup.GET("score/calScore/:rule_id", admin.NewStudentScoreController().CalScore)
		adminGroup.GET("score/assignment/:rule_id", admin.NewStudentScoreController().Assignment)

		//录取规则
		adminGroup.GET("enrollRule/list", admin.NewEnrollRuleController().List)
		adminGroup.POST("enrollRule/add", admin.NewEnrollRuleController().Add)
		adminGroup.POST("enrollRule/edit", admin.NewEnrollRuleController().Edit)
		adminGroup.GET("enrollRule/detail/:id", admin.NewEnrollRuleController().Detail)
		adminGroup.GET("enrollRule/deleted/:id", admin.NewEnrollRuleController().Deleted)

		//录取：
		adminGroup.GET("enroll/initStudent", admin.NewEnrollStudentController().InitStudent)          //初始化学生
		adminGroup.GET("enroll/updateRanking", admin.NewEnrollStudentController().UpdateScoreRanking) //更新成绩排名
		adminGroup.GET("enroll/early", admin.NewEnrollStudentController().EarlyDecision)              //预录取

	}

	//公共接口
	commonGroup := engine.Group("/common/")

	commonGroup.Use(middleware.Cors()).Use(middleware.CheckMember())
	{
		commonGroup.POST("uploader/upload", common.NewUploader().UploadFile)
		commonGroup.GET("excel/import", admin.NewExcelController().Import)
		/*commonGroup.POST("uploader/sliceUpload", common.NewUploader().SliceUpload)*/
	}

}
